package com.ruoyi.web.controller;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Judgmentquestions;
import com.ruoyi.system.service.IJudgmentquestionsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 判断/填空题管理Controller
 *
 * @author ruoyi
 * @date 2022-08-19
 */
@Controller
@RequestMapping("/system/judgmentquestions")
public class JudgmentquestionsController extends BaseController {
    private String prefix = "system/judgmentquestions";

    @Autowired
    private IJudgmentquestionsService judgmentquestionsService;

    @RequiresPermissions("system:judgmentquestions:view")
    @GetMapping()
    public String judgmentquestions() {
        return prefix + "/judgmentquestions";
    }

    /**
     * 查询判断/填空题管理列表
     */
    @RequiresPermissions("system:judgmentquestions:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Judgmentquestions judgmentquestions) {
        startPage();
        List<Judgmentquestions> list = judgmentquestionsService.selectJudgmentquestionsList(judgmentquestions);
        return getDataTable(list);
    }

    /**
     * 导出判断/填空题管理列表
     */
    @RequiresPermissions("system:judgmentquestions:export")
    @Log(title = "判断/填空题管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Judgmentquestions judgmentquestions) {
        List<Judgmentquestions> list = judgmentquestionsService.selectJudgmentquestionsList(judgmentquestions);
        ExcelUtil<Judgmentquestions> util = new ExcelUtil<Judgmentquestions>(Judgmentquestions.class);
        return util.exportExcel(list, "判断/填空题管理数据");
    }

    /**
     * 新增判断/填空题管理
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增保存判断/填空题管理
     */
    @RequiresPermissions("system:judgmentquestions:add")
    @Log(title = "判断/填空题管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Judgmentquestions judgmentquestions) {
        return toAjax(judgmentquestionsService.insertJudgmentquestions(judgmentquestions));
    }

    /**
     * 修改判断/填空题管理
     */
    @RequiresPermissions("system:judgmentquestions:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap) {
        Judgmentquestions judgmentquestions = judgmentquestionsService.selectJudgmentquestionsById(id);
        mmap.put("judgmentquestions", judgmentquestions);
        return prefix + "/edit";
    }

    /**
     * 修改保存判断/填空题管理
     */
    @RequiresPermissions("system:judgmentquestions:edit")
    @Log(title = "判断/填空题管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Judgmentquestions judgmentquestions) {
        return toAjax(judgmentquestionsService.updateJudgmentquestions(judgmentquestions));
    }

    /**
     * 删除判断/填空题管理
     */
    @RequiresPermissions("system:judgmentquestions:remove")
    @Log(title = "判断/填空题管理", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(judgmentquestionsService.deleteJudgmentquestionsByIds(ids));
    }


    @PostMapping("/mylist")
    @ResponseBody
    public AjaxResult getMyList(Judgmentquestions judgmentquestions) {
        return success(judgmentquestionsService.selectJudgmentquestionsList(judgmentquestions));
    }

    @PostMapping("/getById")
    @ResponseBody
    public AjaxResult MygetById(@RequestParam("Id") Long id){
        return success(judgmentquestionsService.selectJudgmentquestionsById(id));
    }


}
